import request from '@/utils/request'

const goodsApi = {
  // 商品统计
  getGoodsStatList: (supplierId) => {
    return request({
      url: `/product/spu/get-count?supplierId=${supplierId}`,
      method: 'GET'
    })
  },
	// 供应商及供应链自营商品列表
	getProductList: (data) => {
		return request({
			url: `/product/spu/page?pageNo=${data.pageNo}&pageSize=${data.pageSize}&tabType=${data.tabType}&name=${data.name}&supplierId=${data.supplierId}`,
			method: 'GET'
		})
	},
	// 直供商品列表
	getSpuTenantPage: (data) => {
		return request({
			url: `/product/spu/getSpuTenantPage?pageNo=${data.pageNo}&pageSize=${data.pageSize}&tabType=${data.tabType}&name=${data.name}`,
			method: 'GET'
		})
	},
	// 获取商品分类模板
	getCategoryTempList: () => {
		return request({
			url: '/product/category-temp/simple-list',
			method: 'GET',
		})
	},
	// 获取商品分类
	getCategoryList: () => {
		return request({
			url: '/product/category/list',
			method: 'GET',
		})
	},
	// 商品详情
	getGoodsDetail: (id) => {
		return request({
			url: `/product/spu/get-detail?id=${id}`,
			method: 'GET'
		})
	},
	// 添加商品
	addProduct: (data) => {
		return request({
			url: `/product/spu/create`,
			method: 'POST',
			data: data,
		})
	},
	// 编辑保存
	updateProduct: (data) => {
		return request({
			url: `/product/spu/update`,
			method: 'PUT',
			data,
		})
	},
	// 上架商品
	listingProducts: (data) => {
		return request({
			url: `/product/spu/listingProducts`,
			method: 'POST',
			data: data,
		})
	},
	// 下架和移除
	removeProduct: (data) => {
		return request({
			url: '/product/spu/update-status',
			method: 'PUT',
			data
		})
	},
	// 取消上架申请
	cancelListing: (id) => {
		return request({
			url: `/product/spu/withdraw?spuId=${id}`,
			method: 'PUT',
		})
	},
	// 商品上架审核
	doAudit: (data) => {
		return request({
			url: `/product/spu/doAudit`,
			method: 'POST',
			data: data,
		})
	},
	// 改价
	changePrices: (data) => {
		return request({
			url: '/product/prices/update',
			method: 'PUT',
			data
		})
	},
	// 统计数据  1全部 2自己
	statisticsData: (type) => {
		return request({
			url: `/trade/order/get-order-spu-num?type=${type}`,
			method: 'GET'
		})
	},
	// 供应商商品列表
	getSupplierGoodsList: (params) => {
		return request({
			url: `/product/spu/page?pageNo=${params.pageNo}&pageSize=${params.pageSize}&tabType=0&supplierId=${params.companyId}`,
			method: 'GET'
		})
	},
  // 获取商城商品数据
  getMallGoodsList: (params) => {
    return request({
      url: '/product/spu/page1',
      method: 'GET',
      params
    })
  },
  // 获取供应商发货地
  getDispatchList: (params) => {
    return request({
      url: '/vms/supplier-deliver-place/page',
      method: 'GET',
      params
    })
  },
}
export default goodsApi